API enhancements for vector datatype#3468
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the vector datatype API by replacing the length‐based constructor with a clearer factory, removing the public Size property (now inferred), converting SqlVector<T> to a readonly struct, and updating the SQL parameter handling and tests to match.
- Refactored
SqlVector<T>: made it areadonly struct, dropped the publicSizeproperty, and addedCreateNull(int length). - Updated
SqlParameterto ignoreSizefor vector types and adjustedPreparelogic. - Revised unit and manual tests to use
CreateNull, removed directSizeassertions, and updated documentation and ref surfaces.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlVector.cs | Converted SqlVector<T> to struct, added CreateNull, removed Size property |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlParameter.cs | Skip applying Size for vector parameters and update Prepare check |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlDataReader.cs | Simplified vector‐to‐string conversion logic |
| src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBuffer.cs | Use CreateNull when returning a null vector |
| src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlTypes/SqlVectorTest.cs | Updated tests to use CreateNull and check Size via ISqlVector |
| src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/VectorTest/NativeVectorFloat32Tests.cs | Removed sizeInbytes, adapted test data and validation |
| src/Microsoft.Data.SqlClient/net*/ref/Microsoft.Data.SqlClient.cs | Updated API surface: SqlVector<T> now readonly struct, added CreateNull |
| doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml | Clarified in docs that Size is ignored for vectors |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3468 +/- ##
==========================================
- Coverage 68.86% 0 -68.87%
==========================================
Files 280 0 -280
Lines 62417 0 -62417
==========================================
- Hits 42982 0 -42982
+ Misses 19435 0 -19435
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
paulmedynski
left a comment
There was a problem hiding this comment.
A few minor comments.
Description
In case specified, it will be ignored.
Issues
Incorporating suggestions from #3382
Testing
Modified existing testcases for above changes.
Guidelines
Please review the contribution guidelines before submitting a pull request: